package com.iiiss.ssh.impl.entities;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;

import com.iiiss.ssh.core.entities.Column;

@Entity(name = Column.ENTITY_NAME)
public class ColumnImpl extends BaseEntityImpl implements Column {

	@Basic
	private String name;

	@ManyToOne(targetEntity = ColumnImpl.class)
	private Column parent;

	@OneToMany(targetEntity = ColumnImpl.class, cascade = CascadeType.ALL)
	private List<Column> children = new ArrayList<Column>();

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Column getParent() {
		return parent;
	}

	public void setParent(Column parent) {
		this.parent = parent;
	}

	public List<Column> getChildren() {
		return children;
	}

	public void setChildren(List<Column> children) {
		this.children = children;
	}

	public String toString() {
		return "{ Column " + getId() + " : " + getName() + ", " + getChildren() + " }";
	}

}
